import requests

headers = {
    "Accept": "application/json, text/javascript, */*; q=0.01",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "Connection": "keep-alive",
    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    "Origin": "https://login.10086.cn",
    "Referer": "https://login.10086.cn/html/login/email_login.html",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Site": "same-origin",
    "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36 Edg/142.0.0.0",
    "X-Requested-With": "XMLHttpRequest",
    "sec-ch-ua": "\"Chromium\";v=\"142\", \"Microsoft Edge\";v=\"142\", \"Not_A Brand\";v=\"99\"",
    "sec-ch-ua-mobile": "?1",
    "sec-ch-ua-platform": "\"Android\""
}
cookies = {
    "WT_FPC": "id=221a9528a9a55f8786f1757401146747:lv=1761306912882:ss=1761306769834",
    "sendflag": "20251109152749912086"
}
url = "https://login.10086.cn/login.htm"

import subprocess
from functools import partial

subprocess.Popen = partial(subprocess.Popen, encoding="utf-8")
import execjs
import time


with open("18.js", "r", encoding="utf-8") as f:
    js_code = f.read()
# 编译 JS 代码
ctx = execjs.compile(js_code)
# 调用解密函数
email = "daiyuling123@foxmail.com"
password = "daiyuling123"
encrypt_email = ctx.call("et", email)
encrypt_password = ctx.call("et", password)
timestamp = int(round(time.time() * 1000))

data = {
    "accountType": "02",
    "pwdType": "03",
    "account": encrypt_email,
    "password": encrypt_password,
    "backUrl": "https://touch.10086.cn/i/",
    "rememberMe": "1",
    "channelID": "12014",
    "protocol": "https:",
    "loginMode": "03",
    "timestamp": timestamp
}
response = requests.post(url, headers=headers, cookies=cookies, data=data)

print(response.text)
print(response)
